var readline = require('readline');
var fileSave = require('file-save');
var DateTime = require('date-time-string');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var date = DateTime.toDateString();
var time = DateTime.toTimeString();


function bu0(i) {
    if (("" + i).length < 5)
        return "0000".substr(0, 5 - ("" + i).length) + i;
    else
        return ("" + i).substr(0, 5);
}

rl.question("Please input ID: ", function(id) {
    rl.question("Please input title: ", function(title) {
        rl.close();
        var of = fileSave("../../doc/" + date +　"-" + bu0(id) + "-" + title + ".md");
        of.write("---\n");
        of.write("id: " + id + "\n");
        of.write("layout: default\n");
        of.write("title: " + title + "\n");
        of.write("---\n");
        of.write("\n");
        of.write("## 任务详情\n");
        of.write("\n");
        of.write("### 需求\n");
        of.write("\n");
        of.write("_需求_\n");
        of.write("\n");
        of.write("### 启动时间 " + date + " " + time + "\n");
        of.write("\n");
        of.write("### 预计完成时间 _" + date + " " + time + "_\n");
        of.write("\n");
        of.write("\n");
        of.write("## 进度报告\n");
        of.write("\n");
        of.write("### 1\n");
        of.write("\n");
        of.write("_第1天进展_\n");
        of.write("\n");
        of.write("#### Todo list\n");
        of.write("_备忘_\n");
        of.write("\n");
        of.write("### 2\n");
        of.write("\n");
        of.write("_第2天进展_\n");
        of.write("\n");
        of.write("### n\n");
        of.write("\n");
        of.write("_第n天进展_\n");
        of.write("\n");
        of.write("\n");
        of.write("## 完成情况\n");
        of.write("\n");
        of.write("### 完成时间 _" + date + " " + time + "_\n");
        of.write("\n");
        of.write("### 逾期 _0天_\n");
        of.write("\n");
        of.write("### 遗留问题\n");
        of.write("\n");
        of.write("_无_\n");
        of.write("\n");
        of.write("### 总结\n");
        of.write("\n");
        of.write("_总结_\n");
        of.write("\n");
        of.write("\n");
        of.write("## 长期验证\n");
        of.write("\n");
        of.write("### 引出新问题\n");
        of.write("\n");
        of.write("_无_\n");
    });
});

